<template>
  <div class="content-view">
    <template v-if="status === PageStatus.Loading">
      <div class="loading">
        <div class="box">
          <i class="el-icon-loading icon" />
          <span class="txt">数据加载中请稍后....</span>
        </div>
      </div>
    </template>
    <template v-if="status === PageStatus.Ready">
      <div v-if="$route.meta.isBreadcrumb !== false" class="crumbs">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item
            v-for="(item, index) in $route.matched"
            :key="item.path"
          >
            <template v-if="index == 0">
              <i :class="item.meta.iconCls" />
            </template>
            {{ item.meta.name }}
          </el-breadcrumb-item>
        </el-breadcrumb>
      </div>
      <div class="wrap-body">
        <slot />
      </div>
    </template>
    <template v-if="status === PageStatus.Error">
      <div class="error">
        <div class="box">
          <i class="el-icon-warning icon" />
          <span class="txt">数据加载失败，点击<a href="javascript: void(0);" @click="resetInit">这里</a>重试</span>
        </div>
      </div>
    </template>
  </div>
</template>
<script>
import { PageStatus } from '@/config'
export default {
  name: 'LContentView',
  props: {
    status: {
      type: Number,
      default: PageStatus.Loading
    }
  },
  data() {
    return {
      PageStatus,
      matched: []
    }
  },
  computed: {
  },
  created() {
    console.log('-----lui package contentView----- created')
  },
  methods: {
    resetInit() {
      this.$emit('init')
    }
  }
}
</script>
<style lang="less" scoped>
  .content-view {
    height: 100%;

    .wrap-body {
      width: 100%;
      height: 100%;
      padding: 30px;
      background: #fff;
      border: 1px solid #ddd;
      border-radius: 5px;
      box-sizing: border-box;
    }

    .loading {
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;

    }

    .error {
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .box {
      width: 80%;
      text-align: center;
      line-height: 80px;
      border: 1px solid #ccc;

      .icon {
        font-size: 30px;
        vertical-align: middle;
        margin-right: 10px;
      }
    }
  }
</style>
